package terra.model;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

import terra.Config;
import terra.managers.DefManager;
import terra.managers.LightManager;
import terra.managers.ResourceManager;
import terra.slick.GameState;

public class Door extends GameObject {

	public byte opened;
	
	public void render(Graphics g){
		int x1 = GameState.getInstance().getTiledOffsetX()-4;
		int y1 = GameState.getInstance().getTiledOffsetY()-4;
		Image image;
		if (opened == 1){
			image = ResourceManager.getImage(DefManager.npcDefs.get(getId()).getStringProperty("image")+"_opened");
		}else {
			image = ResourceManager.getImage(DefManager.npcDefs.get(getId()).getStringProperty("image")+"_closed");
		}
		LightManager.getInstance().blend((int)(getX()/Config.tileSize-x1),(int)(getY()/Config.tileSize-y1), image);
		image.draw(getX(), getY());
	}	
}
